﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace slashchange
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            txtContent.Text = "";
        }

        private void btnChange_Click(object sender, EventArgs e)
        {
            string str = txtContent.Text;

            if (str == null)
            {
                return;
            }

            str = str.Replace("\\", "/");

            txtContent.Text = str;

            Clipboard.SetDataObject(str);
        }



        private void btnChange2_Click(object sender, EventArgs e)
        {
            string str = txtContent.Text;

            if (String.IsNullOrEmpty(str))
            {
                return;
            }

            str = str.Replace("/", "\\");

            txtContent.Text = str;

            Clipboard.SetDataObject(str);
        }


        private void btnPaste_Click(object sender, EventArgs e)
        {
            IDataObject iData = Clipboard.GetDataObject();
            if (iData.GetDataPresent(DataFormats.Text))
            {
                txtContent.Text = (String)iData.GetData(DataFormats.Text);
            }
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            string str = txtContent.Text;

            if (str == null)
            {
                return;
            }

            Clipboard.SetDataObject(str);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            IDataObject iData = Clipboard.GetDataObject();
            if (iData.GetDataPresent(DataFormats.Text))
            {
                txtContent.Text = (String)iData.GetData(DataFormats.Text);
            }
        }
    }
}
